package com.example.config;


import org.eclipse.milo.opcua.sdk.client.api.identity.AnonymousProvider;
import org.eclipse.milo.opcua.sdk.client.api.identity.IdentityProvider;
import org.eclipse.milo.opcua.stack.core.security.SecurityPolicy;
import org.eclipse.milo.opcua.stack.core.types.structured.EndpointDescription;
import org.springframework.stereotype.Component;

import java.util.function.Predicate;


@Component
public class OpcUaConfig {

    /**
     * 获取巴拉素选煤厂WinCC server的opc ua服务地址
     * @return
     */
    public String getEndpointUrl() {
        return "opc.tcp://XmcWinCCServer:4862";
    }

    public Predicate<? super EndpointDescription> endpointFilter() {
        return e -> true;
    }

    /**
     * 连接服务器的安全策略
     * None、Basic128Rsa15、Basic256、Basic256Sha256、Aes128_Sha256_RsaOaep、Aes256_Sha256_RsaPss
     */
    public SecurityPolicy getSecurityPolicy() {
        return SecurityPolicy.None;
    }

    /**
     * 提供身份验证
     */
    public IdentityProvider getIdentityProvider() {
        return new AnonymousProvider();
    }

}
